/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package evidence.controler;

import evidence.model.IModel;
import evidence.view.IAbstractView;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;

/**
 *
 * @author Protheo
 */
public abstract class AbstractControler implements IAbstractControler, PropertyChangeListener{
    /**
     *
     */
    protected ArrayList<IAbstractView> registredView;
    /**
     * 
     */
    protected IModel model = null;

    public AbstractControler(){
        registredView = new ArrayList<IAbstractView>();
    }

    public void registerModel(IModel model) {
        if (this.model == null){
            this.model = model;
            this.model.addPropertyChangeListener(this);
        }
    }

    public void addView(IAbstractView okno) {
        this.registredView.add(okno);
    }

    public void removeView(IAbstractView okno) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void propertyChange(PropertyChangeEvent evt) {
        for (IAbstractView okno : registredView) {
            okno.modelChaneged(evt);
        }
    }

}
